package com.boot.stream;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.stereotype.Component;

/**
 * @author 霜寒 <1621856595@qq.com>
 * @date 2021/7/31 21:35
 **/
@Component
@Slf4j
public class Test {

    private final StreamBridge streamBridge;

    public Test(StreamBridge streamBridge) {
        this.streamBridge = streamBridge;
    }

    //    public void streamTest(String app, int i) {
    //        String out = "topic-out-0";
    //        String msg = app + "-Topic-" + out + "-Num-" + i;
    //        log.info("{} send {}: {}", app, out, msg);
    //        streamBridge.send(out, msg);
    //    }

    public void streamTest1(String app, int i) {
        String out = "topic1-out-0";
        String msg = app + "-Topic " + out + " Num-" + i;
        log.info("{} send {}: {}", app, out, msg);
        streamBridge.send(out, msg);
    }

    public void streamTest2(String app, int i) {
        String out = "topic2-out-0";
        String msg = app + "-Topic-" + out + "-Num-" + i;
        log.info("{} send {}: {}", app, out, msg);
        streamBridge.send(out, msg);
    }


}
